import Vue from 'vue';
import Router from 'vue-router';
import abstract from '../views/common/abstract';
import home from '../views/index';
Vue.use(Router);

let baseRoute = [
 {
  path: '/',
  name: '首页',
  leaf:true,
  component: (resolve) => require(['../views/index.vue'], resolve),
/*  children:[
    {
       path: '/assetmanage',
        name: '资产管理',
        // component: abstract,
        // component: home,
        children:[
           {
            path:'/accountassets',
            name:'账户资产',
            component: (resolve) => require(['../views/accountassets.vue'], resolve),
            
          },          
          {
            path:'/btcxexcharge',
            name:'BTCX兑换',
            component: (resolve) => require(['../views/btcxexcharge.vue'], resolve),

          },
          {
            path:'/ccdeal',
            name:'C2C交易',
            component: (resolve) => require(['../views/ccdeal.vue'], resolve),

          },
          {
            path:'/withdrawalsmanage',
            name:'提现地址管理',
            component: (resolve) => require(['../views/withdrawalsmanage.vue'], resolve),

          }
        ]
    }
  ]*/
}, 
{
  path: '/login',
  name: '登录',
  leaf:true,
  hidden:true,
  component: (resolve) => require(['../views/login.vue'], resolve)
},{
  path: '/register',
  name: '注册',
  leaf:true,
  hidden:true,
  component: (resolve) => require(['../views/register.vue'], resolve)
},{
  path: '/transaction',
  name: '交易中心',
  leaf:true,
  component: (resolve) => require(['../views/transaction.vue'], resolve)
},{
  path: '/assetmanage',
  name: '资产管理',
  // component: abstract,
  component: home,

  children:[
    {
      path:'accountassets',
      name:'账户资产',
      component: (resolve) => require(['../views/accountassets.vue'], resolve),
      
    },
    {
      path:'btcxexcharge',
      name:'BTCX兑换',
      component: (resolve) => require(['../views/btcxexcharge.vue'], resolve),

    },
    {
      path:'ccdeal',
      name:'C2C交易',
      component: (resolve) => require(['../views/ccdeal.vue'], resolve),

    },
    {
      path:'withdrawalsmanage',
      name:'提现地址管理',
      component: (resolve) => require(['../views/withdrawalsmanage.vue'], resolve),

    }
  ]
},{
  path: '/order',
  name: '订单',
  component: home,  
  children:[
    {
      path:'entrustrecord',
      name:'委托记录',
      component: (resolve) => require(['../views/entrustrecord.vue'], resolve),
      
    },
    {
      path:'dealrecord',
      name:'成交记录',
      component: (resolve) => require(['../views/dealrecord.vue'], resolve),
      
    },
    {
      path:'rechargerecord',
      name:'充值记录',
      component: (resolve) => require(['../views/rechargerecord.vue'], resolve),
      
    },
    {
      path:'withdrawalsrecord',
      name:'提现记录',
      component: (resolve) => require(['../views/withdrawalsrecord.vue'], resolve),
      
    }
  ]
},{
  path: '/personalcenter',
  name: '个人中心',
  leaf:true,  
  component: (resolve) => require(['../views/personalcenter.vue'], resolve),
  children:[
    {
      path:'identity',
      name:'身份认证',
      component: (resolve) => require(['../views/identity.vue'], resolve),
    },
    {
      path:'setpassword',
      name:'登录密码',
      component: (resolve) => require(['../views/setpassword.vue'], resolve),
    },
    {
      path:'setpaypassword',
      name:'资金密码',
      component: (resolve) => require(['../views/setpaypassword.vue'], resolve),
    },
    {
      path: 'forgetpaypassword',
      name: '找回资金密码',
      component: (resolve) => require(['../views/forgetpaypassword.vue'], resolve)
    },
   
    {
      path: 'setphone',
      name: '绑定手机',
      component: (resolve) => require(['../views/setphone.vue'], resolve)
    },
  ]
}, 
{
  path: '/forgetpassword',
  name: '找回登录密码',
  hidden:true,

  component: (resolve) => require(['../views/forgetpassword.vue'], resolve)
},/* {
  path: '/newhelp',
  name: '新手帮助',
  leaf:true,  
  component: (resolve) => require(['../views/newhelp.vue'], resolve)
},*/ {
  path: '/401',
  name: '无权访问',
  hidden:true,
  component: (resolve) => require(['../views/common/401.vue'], resolve)
}, {
  path: '/404',
  name: '找不到页面',
  hidden:true,
  component: (resolve) => require(['../views/common/404.vue'], resolve)
}];

let router = new Router({
  routes: baseRoute
});

router.beforeEach((to, from, next) => {
  let routeName = to.meta.name || to.name;
  window.document.title = (routeName ? routeName + ' - ' : '') + '交易平台';
  next();
});

export default router;
